package com.shop.controller;

import com.shop.service.GoodsService;
import com.shop.service.impl.GoodsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author:zyn
 * @Date:2025/9/19--15:30:03
 */
@WebServlet("/deleteGoods.do")
public class DeleteGoodsServlet extends HttpServlet {
    private GoodsService gs=new GoodsServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int goodsId;
        try {
            goodsId=Integer.parseInt(req.getParameter("goodsId"));
            gs.delelteGoodsById(goodsId);
            req.getRequestDispatcher("getGoods.do").forward(req,resp);
        }catch(Exception e){
           resp.sendRedirect("login.jsp");
        }
    }
}
